#include "vtkStructuredPointsReader.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkImageCast.h"
#include "vtkColorTransferFunction.h"
#include "vtkPiecewiseFunction.h"
#include "vtkVolumeProperty.h"
#include "vtkVolumeRayCastCompositeFunction.h"
#include "vtkVolumeRayCastMIPFunction.h"
#include "vtkVolumeRayCastMapper.h"
#include "vtkFixedPointVolumeRayCastMapper.h"
#include "vtkImageGaussianSmooth.h"
#include "vtkLookupTable.h"
#include "vtkImageData.h"
#include "vtkContourFilter.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkPLOT3DReader.h"
#include "vtkProbeFilter.h"
#include "vtkImageMapToColors.h"
#include "vtkPolyDataReader.h"
#include "vtkTubeFilter.h"
#include "vtkImageClip.h"
#include "vtkGPUVolumeRayCastMapper.h"
#include "vtkTubeFilter.h"


//int main(int argc, char *argv[])
//{
//	/*if (argc != 2) {
//		return 0;
//	}
//
//	const char *volumeFile = argv[1];*/
//
//	const char *volumeFile = "\\\\nabla.cs.purdue.edu\\visdata\\Ziang\\CoherenceStructure\\Results\\heart\\DTI\\edges.vtk";
//
//	vtkStructuredPointsReader *pVolumeReader = vtkStructuredPointsReader::New();
//	pVolumeReader->SetFileName(volumeFile);
//	pVolumeReader->Update();
//
//	vtkImageGaussianSmooth *gaussianSmoothFilter = vtkImageGaussianSmooth::New(); 
//	gaussianSmoothFilter->SetInputConnection(pVolumeReader->GetOutputPort());
//	gaussianSmoothFilter->SetStandardDeviation(1.0, 1.0, 1.0);
//	gaussianSmoothFilter->SetDimensionality(3);
//	gaussianSmoothFilter->Update();
//
//	vtkImageClip *clip = vtkImageClip::New();
//	clip->SetInputConnection(pVolumeReader->GetOutputPort());
//	clip->SetOutputWholeExtent(0, 512, 0, 256, 0, 600);
//	clip->ClipDataOn();
//
//	vtkImageCast *pImageCast = vtkImageCast::New();
//	pImageCast->SetInputConnection(clip->GetOutputPort());
//	pImageCast->SetOutputScalarTypeToUnsignedChar();
//	pImageCast->Update();
//
//	double range[2] = {0.0, 255.0};
//	pImageCast->GetOutput()->GetScalarRange(range);
//	printf("Range (%f, %f)\n", range[0], range[1]);
//
//	// create transfer function mapping scalar value to opacity
//	vtkPiecewiseFunction *pOpacityTF = vtkPiecewiseFunction::New();
//	pOpacityTF->AdjustRange(range);
//	pOpacityTF->AddPoint(0, 0.0);
//	pOpacityTF->AddPoint(30, 0.0);
//	pOpacityTF->AddPoint(35, 1.0);
//	pOpacityTF->AddPoint(200, 1.0);
//	pOpacityTF->AddPoint(255, 1.0);
//
//	// create transfer function mapping scalar value to color
//	vtkColorTransferFunction *pColorTF = vtkColorTransferFunction::New();
//	pColorTF->AdjustRange(range);
//	pColorTF->SetColorSpaceToRGB();
//	pColorTF->AddRGBPoint(0.0, 1.0, 1.0, 1.0);
//	pColorTF->AddRGBPoint(50, 1.0, 1.0, 1.0);
//	pColorTF->AddRGBPoint(100, 1.0, 1.0, 1.0);
//	pColorTF->AddRGBPoint(255, 1.0, 1.0, 1.0);
//	//pColorTF->AddRGBPoint(0.0, 1.0, 0.929, 0.627);
//	//pColorTF->AddRGBPoint(50, 0.996, 0.698, 0.298);
//	//pColorTF->AddRGBPoint(100, 0.941, 0.2313, 0.125);
//	//pColorTF->AddRGBPoint(255, 0.941, 0.2313, 0.125);
//
//	// create a vtkVolumeProperty, and set the volume property
//	vtkVolumeProperty *pVolumeProperty = vtkVolumeProperty::New();
//	pVolumeProperty->SetColor(0, pColorTF);
//	pVolumeProperty->SetScalarOpacity(0, pOpacityTF);
//	pVolumeProperty->ShadeOn();
//	pVolumeProperty->SetInterpolationTypeToLinear();
//
//	// create a vtkVolumeRayCastCompositeFunction
//	vtkVolumeRayCastCompositeFunction *pCompositeFunction = vtkVolumeRayCastCompositeFunction::New();
//	// create a vtkVolumeRayCastMIPFunction
//	vtkVolumeRayCastMIPFunction *pMIPFunction = vtkVolumeRayCastMIPFunction::New();
//	pMIPFunction->SetMaximizeMethodToOpacity();
//
//	// create a vtkVolumeRayCastMapper
//	vtkGPUVolumeRayCastMapper *pVolumeRayCastMapper = vtkGPUVolumeRayCastMapper::New();
//	//pVolumeRayCastMapper->SetVolumeRayCastFunction(pCompositeFunction);
//	pVolumeRayCastMapper->SetBlendModeToComposite();
//	pVolumeRayCastMapper->SetInputConnection(pImageCast->GetOutputPort());
//	pVolumeRayCastMapper->SetSampleDistance(0.2);
//
//	//vtkVolumeRayCastMapper *pVolumeRayCastMapper = vtkVolumeRayCastMapper::New();
//	//pVolumeRayCastMapper->SetVolumeRayCastFunction(pCompositeFunction);
//	//pVolumeRayCastMapper->SetInputConnection(pImageCast->GetOutputPort());
//	//pVolumeRayCastMapper->SetSampleDistance(0.2);
//
//	//vtkFixedPointVolumeRayCastMapper *pVolumeRayCastMapper = vtkFixedPointVolumeRayCastMapper::New();
//	//pVolumeRayCastMapper->SetBlendModeToComposite();
//	//pVolumeRayCastMapper->SetInputConnection(pImageCast->GetOutputPort());
//	//pVolumeRayCastMapper->SetSampleDistance(0.2);
//
//	// create a vtkVolume, and set mapper & property
//	vtkVolume *pVolume = vtkVolume::New();
//	pVolume->SetMapper(pVolumeRayCastMapper);
//	pVolume->SetProperty(pVolumeProperty);
//
//
//
//	// Create the graphics structure. The renderer renders into the 
//	// render window. The render window interactor captures mouse events
//	// and will perform appropriate camera or actor manipulation
//	// depending on the nature of the events.
//	//
//	vtkRenderer *pRenderer = vtkRenderer::New();
//	vtkRenderWindow *pRenderWindow = vtkRenderWindow::New();
//	pRenderWindow->AddRenderer(pRenderer);
//	vtkRenderWindowInteractor *pRenderWindowInteractor = 
//		vtkRenderWindowInteractor::New();
//	pRenderWindowInteractor->SetRenderWindow(pRenderWindow);
//
//	// Add the volume to the renderer
//	pRenderer->AddVolume(pVolume);
//
//	// set the background and size
//	pRenderer->SetBackground(0.0, 0.0, 0.0);
//	pRenderWindow->SetParentId(NULL);
//	pRenderWindow->SetSize(1024, 1024);
//	//pRenderWindow->SetAAFrames(4);
//	pRenderer->ResetCamera();
//
//	pRenderWindow->Render();
//
//	// This starts the event loop and as a side effect causes an initial render.
//	pRenderWindowInteractor->Start();
//
//	return 0;
//}


int main(int argc, char *argv[])
{
	//if (argc != 4) {
	//	return 0;
	//}

	const char *bVolumeFile = argv[1];
	const char *hVolumeFile = argv[2];

	const char *fiberFile1 = argv[3];
	//const char *fiberFile2 = argv[4];
	//const char *fiberFile3 = argv[5];
	//const char *fiberFile4 = argv[6];


	vtkPolyDataReader *pFiberReader1 = vtkPolyDataReader::New();
	pFiberReader1->SetFileName(fiberFile1);
	vtkTubeFilter *pTube1 = vtkTubeFilter::New();
	pTube1->SetInputConnection(pFiberReader1->GetOutputPort());
	pTube1->SetRadius(0.1);
	pTube1->SetNumberOfSides(8);
	vtkPolyDataMapper *pFiberapper1 = vtkPolyDataMapper::New();
	pFiberapper1->SetInputConnection(pTube1->GetOutputPort());
	vtkActor *pFiberActor1 = vtkActor::New();
	pFiberActor1->SetMapper(pFiberapper1);

	//vtkPolyDataReader *pFiberReader2 = vtkPolyDataReader::New();
	//pFiberReader2->SetFileName(fiberFile2);
	//vtkTubeFilter *pTube2 = vtkTubeFilter::New();
	//pTube2->SetInputConnection(pFiberReader2->GetOutputPort());
	//pTube2->SetRadius(1.0);
	//pTube2->SetNumberOfSides(8);
	//vtkPolyDataMapper *pFiberapper2 = vtkPolyDataMapper::New();
	//pFiberapper2->SetInputConnection(pTube2->GetOutputPort());
	//vtkActor *pFiberActor2 = vtkActor::New();
	//pFiberActor2->SetMapper(pFiberapper2);

	//vtkPolyDataReader *pFiberReader3 = vtkPolyDataReader::New();
	//pFiberReader3->SetFileName(fiberFile3);
	//vtkTubeFilter *pTube3 = vtkTubeFilter::New();
	//pTube3->SetInputConnection(pFiberReader3->GetOutputPort());
	//pTube3->SetRadius(1.0);
	//pTube3->SetNumberOfSides(8);
	//vtkPolyDataMapper *pFiberapper3 = vtkPolyDataMapper::New();
	//pFiberapper3->SetInputConnection(pTube3->GetOutputPort());
	//vtkActor *pFiberActor3 = vtkActor::New();
	//pFiberActor3->SetMapper(pFiberapper3);
	







	vtkStructuredPointsReader *pBaseVolumeReader = vtkStructuredPointsReader::New();
	pBaseVolumeReader->SetFileName(bVolumeFile);
	pBaseVolumeReader->Update();

	vtkImageGaussianSmooth *gaussianSmoothFilter = vtkImageGaussianSmooth::New(); 
	gaussianSmoothFilter->SetInputConnection(pBaseVolumeReader->GetOutputPort());
	gaussianSmoothFilter->SetStandardDeviation(1.0, 1.0, 1.0);
	gaussianSmoothFilter->SetDimensionality(3);
	gaussianSmoothFilter->Update();

	//vtkImageClip *clip = vtkImageClip::New();
	//clip->SetInputConnection(pBaseVolumeReader->GetOutputPort());
	//clip->SetOutputWholeExtent(0, 512, 0, 512, 0, 120);
	//clip->ClipDataOn();

	vtkImageCast *pBaseImageCast = vtkImageCast::New();
	pBaseImageCast->SetInputConnection(gaussianSmoothFilter->GetOutputPort());
	pBaseImageCast->SetOutputScalarTypeToUnsignedChar();
	pBaseImageCast->Update();

	double range[2] = {0.0, 255.0};
	pBaseImageCast->GetOutput()->GetScalarRange(range);
	printf("Range (%f, %f)\n", range[0], range[1]);

	// create transfer function mapping scalar value to opacity
	vtkPiecewiseFunction *pBaseOpacityTF = vtkPiecewiseFunction::New();
	pBaseOpacityTF->AdjustRange(range);
	pBaseOpacityTF->AddPoint(0, 0.0);
	pBaseOpacityTF->AddPoint(225, 0.0);
	pBaseOpacityTF->AddPoint(230, 1.0);
	pBaseOpacityTF->AddPoint(250, 1.0);
	pBaseOpacityTF->AddPoint(254, 1.0);

	// create transfer function mapping scalar value to color
	vtkColorTransferFunction *pBaseColorTF = vtkColorTransferFunction::New();
	pBaseColorTF->AdjustRange(range);
	pBaseColorTF->SetColorSpaceToRGB();

	pBaseColorTF->AddRGBPoint(0.0, 1.0, 1.0, 1.0);
	pBaseColorTF->AddRGBPoint(50,  1.0, 1.0, 1.0);
	pBaseColorTF->AddRGBPoint(100, 1.0, 1.0, 1.0);
	pBaseColorTF->AddRGBPoint(250, 1.0, 1.0, 1.0);
	/*pBaseColorTF->AddRGBPoint(0.0, 1,	0.0,	0.0);
	pBaseColorTF->AddRGBPoint(10,  1,	0.0,	0.0);
	pBaseColorTF->AddRGBPoint(100, 1,	0.9,	0.0);
	pBaseColorTF->AddRGBPoint(200, 1,	0.95,	0.0);
	pBaseColorTF->AddRGBPoint(255, 1,	1.0,	0.0);*/

	// create a vtkVolumeProperty, and set the volume property
	vtkVolumeProperty *pBaseVolumeProperty = vtkVolumeProperty::New();
	pBaseVolumeProperty->SetColor(0, pBaseColorTF);
	pBaseVolumeProperty->SetScalarOpacity(0, pBaseOpacityTF);
	pBaseVolumeProperty->ShadeOn();
	pBaseVolumeProperty->SetInterpolationTypeToLinear();

	// create a vtkVolumeRayCastCompositeFunction
	vtkVolumeRayCastCompositeFunction *pBaseCompositeFunction = vtkVolumeRayCastCompositeFunction::New();
	// create a vtkVolumeRayCastMIPFunction
	vtkVolumeRayCastMIPFunction *pBaseMIPFunction = vtkVolumeRayCastMIPFunction::New();
	pBaseMIPFunction->SetMaximizeMethodToOpacity();
	

	vtkGPUVolumeRayCastMapper *pBaseVolumeRayCastMapper = vtkGPUVolumeRayCastMapper::New();
	//pVolumeRayCastMapper->SetVolumeRayCastFunction(pCompositeFunction);
	pBaseVolumeRayCastMapper->SetBlendModeToComposite();
	pBaseVolumeRayCastMapper->SetInputConnection(pBaseImageCast->GetOutputPort());
	pBaseVolumeRayCastMapper->SetSampleDistance(0.2);

	//vtkVolumeRayCastMapper *pBaseVolumeRayCastMapper = vtkVolumeRayCastMapper::New();
	//pBaseVolumeRayCastMapper->SetVolumeRayCastFunction(pBaseCompositeFunction);
	//pBaseVolumeRayCastMapper->SetBlendModeToMaximumIntensity();
	////pBaseVolumeRayCastMapper->SetBlendModeToComposite();
	//pBaseVolumeRayCastMapper->SetInputConnection(pBaseImageCast->GetOutputPort());
	//pBaseVolumeRayCastMapper->SetSampleDistance(0.5);

	// create a vtkVolume, and set mapper & property
	vtkVolume *pBaseVolume = vtkVolume::New();
	pBaseVolume->SetMapper(pBaseVolumeRayCastMapper);
	pBaseVolume->SetProperty(pBaseVolumeProperty);



	//vtkStructuredPointsReader *pHLVolumeReader = vtkStructuredPointsReader::New();
	//pHLVolumeReader->SetFileName(hVolumeFile);
	//pHLVolumeReader->Update();

	//vtkImageGaussianSmooth *gaussianSmoothFilter = vtkImageGaussianSmooth::New(); 
	//gaussianSmoothFilter->SetInputConnection(pHLVolumeReader->GetOutputPort());
	//gaussianSmoothFilter->SetStandardDeviation(1.0, 1.0, 1.0);
	//gaussianSmoothFilter->SetDimensionality(3);
	//gaussianSmoothFilter->Update();

	//vtkImageCast *pHLImageCast = vtkImageCast::New();
	//pHLImageCast->SetInputConnection(gaussianSmoothFilter->GetOutputPort());
	//pHLImageCast->SetOutputScalarTypeToUnsignedChar();
	//pHLImageCast->Update();

	//pHLImageCast->GetOutput()->GetScalarRange(range);
	//printf("Range (%f, %f)\n", range[0], range[1]);

	//// create transfer function mapping scalar value to opacity
	//vtkPiecewiseFunction *pHLOpacityTF = vtkPiecewiseFunction::New();
	//pHLOpacityTF->AdjustRange(range);
	//pHLOpacityTF->AddPoint(0, 0.0);
	//pHLOpacityTF->AddPoint(30, 0.0);
	//pHLOpacityTF->AddPoint(40, 1.0);
	//pHLOpacityTF->AddPoint(200, 1.0);
	//pHLOpacityTF->AddPoint(255, 1.0);

	//// create transfer function mapping scalar value to color
	//vtkColorTransferFunction *pHLColorTF = vtkColorTransferFunction::New();
	//pHLColorTF->AdjustRange(range);
	//pHLColorTF->SetColorSpaceToRGB();
	////
	//////0.4,	0.760784314,	0.647058824
	//////0.988235294,	0.552941176,	0.384313725
	//////0.905882353,	0.541176471,	0.764705882
	//////0.552941176,	0.62745098,	0.796078431

	//pHLColorTF->AddRGBPoint(0,  0.905882353,	0.541176471,	0.764705882);
	//pHLColorTF->AddRGBPoint(50, 0.905882353,	0.541176471,	0.764705882);
	//pHLColorTF->AddRGBPoint(100,0.905882353,	0.541176471,	0.764705882);
	//pHLColorTF->AddRGBPoint(255,0.905882353,	0.541176471,	0.764705882);

	//// create a vtkVolumeProperty, and set the volume property
	//vtkVolumeProperty *pHLVolumeProperty = vtkVolumeProperty::New();
	//pHLVolumeProperty->SetColor(0, pHLColorTF);
	//pHLVolumeProperty->SetScalarOpacity(0, pHLOpacityTF);
	//pHLVolumeProperty->ShadeOn();
	//pHLVolumeProperty->SetInterpolationTypeToLinear();

	//// create a vtkVolumeRayCastCompositeFunction
	//vtkVolumeRayCastCompositeFunction *pHLCompositeFunction = vtkVolumeRayCastCompositeFunction::New();
	//// create a vtkVolumeRayCastMIPFunction
	//vtkVolumeRayCastMIPFunction *pHLMIPFunction = vtkVolumeRayCastMIPFunction::New();
	//pHLMIPFunction->SetMaximizeMethodToOpacity();

	//vtkVolumeRayCastMapper *pHLVolumeRayCastMapper = vtkVolumeRayCastMapper::New();
	//pHLVolumeRayCastMapper->SetVolumeRayCastFunction(pHLCompositeFunction);
	//pHLVolumeRayCastMapper->SetInputConnection(pHLImageCast->GetOutputPort());
	//pHLVolumeRayCastMapper->SetSampleDistance(0.2);

	//// create a vtkVolume, and set mapper & property
	//vtkVolume *pHLVolume = vtkVolume::New();
	//pHLVolume->SetMapper(pHLVolumeRayCastMapper);
	//pHLVolume->SetProperty(pHLVolumeProperty);



	// Create the graphics structure. The renderer renders into the 
	// render window. The render window interactor captures mouse events
	// and will perform appropriate camera or actor manipulation
	// depending on the nature of the events.
	//
	vtkRenderer *pRenderer = vtkRenderer::New();
	vtkRenderWindow *pRenderWindow = vtkRenderWindow::New();
	pRenderWindow->AddRenderer(pRenderer);
	vtkRenderWindowInteractor *pRenderWindowInteractor = 
		vtkRenderWindowInteractor::New();
	pRenderWindowInteractor->SetRenderWindow(pRenderWindow);

	// Add the volume to the renderer
	pRenderer->AddVolume(pBaseVolume);
	//pRenderer->AddVolume(pHLVolume);

	//pRenderer->AddActor(pFiberActor1);
	//pRenderer->AddActor(pFiberActor2);
	//pRenderer->AddActor(pFiberActor3);


	//// 1. Use a render window with alpha bits (as initial value is 0 (false)):
	//pRenderWindow->SetAlphaBitPlanes(true);

	//// 2. Force to not pick a framebuffer with a multisample buffer
	//// (as initial value is 8):
	//pRenderWindow->SetMultiSamples(0);

	//// 3. Choose to use depth peeling (if supported) (initial value is 0 (false)):
	//pRenderer->SetUseDepthPeeling(true);

	//// 4. Set depth peeling parameters
	//// - Set the maximum number of rendering passes (initial value is 4):
	//pRenderer->SetMaximumNumberOfPeels(16);
	//// - Set the occlusion ratio (initial value is 0.0, exact image):
	//pRenderer->SetOcclusionRatio(0.0);

	// set the background and size
	pRenderer->SetBackground(0.0, 0.0, 0.0);
	pRenderWindow->SetParentId(NULL);
	pRenderWindow->SetSize(1024, 1024);
	//pRenderWindow->SetAAFrames(4);
	pRenderer->ResetCamera();

	//pRenderer->SetAmbient(1.0, 1.0, 1.0);

	pRenderWindow->Render();

	// This starts the event loop and as a side effect causes an initial render.
	pRenderWindowInteractor->Start();

	return 0;
}


//
//int main(int argc, char *argv[])
//{
//	vtkStructuredPointsReader *pBaseVolumeReader = vtkStructuredPointsReader::New();
//	pBaseVolumeReader->SetFileName(argv[1]);
//	pBaseVolumeReader->Update();
//
//	vtkImageGaussianSmooth *gaussianSmoothFilter = vtkImageGaussianSmooth::New(); 
//	gaussianSmoothFilter->SetInputConnection(pBaseVolumeReader->GetOutputPort());
//	gaussianSmoothFilter->SetStandardDeviation(1.0, 1.0, 1.0);
//	gaussianSmoothFilter->SetDimensionality(3);
//	gaussianSmoothFilter->Update();
//
//	//vtkImageClip *clip = vtkImageClip::New();
//	//clip->SetInputConnection(gaussianSmoothFilter->GetOutputPort());
//	//clip->SetOutputWholeExtent(0, 512, 0, 512, 0, 120);
//	//clip->ClipDataOn();
//
//	vtkImageCast *pBaseImageCast = vtkImageCast::New();
//	pBaseImageCast->SetInputConnection(gaussianSmoothFilter->GetOutputPort());
//	pBaseImageCast->SetOutputScalarTypeToUnsignedChar();
//	pBaseImageCast->Update();
//
//	double range[2] = {0.0, 255.0};
//	pBaseImageCast->GetOutput()->GetScalarRange(range);
//	printf("Range (%f, %f)\n", range[0], range[1]);
//
//	// create transfer function mapping scalar value to opacity
//	vtkPiecewiseFunction *pBaseOpacityTF = vtkPiecewiseFunction::New();
//	pBaseOpacityTF->AdjustRange(range);
//	pBaseOpacityTF->AddPoint(0, 0.0);
//	pBaseOpacityTF->AddPoint(30, 0.0);
//	pBaseOpacityTF->AddPoint(35, 0.01);
//	pBaseOpacityTF->AddPoint(100, 0.015);
//	pBaseOpacityTF->AddPoint(255, 0.015);
//
//	// create transfer function mapping scalar value to color
//	vtkColorTransferFunction *pBaseColorTF = vtkColorTransferFunction::New();
//	pBaseColorTF->AdjustRange(range);
//	pBaseColorTF->SetColorSpaceToRGB();
//
//	pBaseColorTF->AddRGBPoint(0,   1.0, 1.0, 1.0);
//	pBaseColorTF->AddRGBPoint(50,  1.0, 1.0, 1.0);
//	pBaseColorTF->AddRGBPoint(100, 1.0, 1.0, 1.0);
//	pBaseColorTF->AddRGBPoint(255, 1.0, 1.0, 1.0);
//
//	// create a vtkVolumeProperty, and set the volume property
//	vtkVolumeProperty *pBaseVolumeProperty = vtkVolumeProperty::New();
//	pBaseVolumeProperty->SetColor(0, pBaseColorTF);
//	pBaseVolumeProperty->SetScalarOpacity(0, pBaseOpacityTF);
//	pBaseVolumeProperty->ShadeOff();
//	pBaseVolumeProperty->SetInterpolationTypeToLinear();
//
//	// create a vtkVolumeRayCastCompositeFunction
//	vtkVolumeRayCastCompositeFunction *pBaseCompositeFunction = vtkVolumeRayCastCompositeFunction::New();
//	pBaseCompositeFunction->SetCompositeMethodToInterpolateFirst();
//
//	vtkVolumeRayCastMapper *pBaseVolumeRayCastMapper = vtkVolumeRayCastMapper::New();
//	pBaseVolumeRayCastMapper->SetVolumeRayCastFunction(pBaseCompositeFunction);
//	pBaseVolumeRayCastMapper->SetBlendModeToMaximumIntensity();
//	pBaseVolumeRayCastMapper->SetInputConnection(pBaseImageCast->GetOutputPort());
//	pBaseVolumeRayCastMapper->SetSampleDistance(0.5);
//
//	// create a vtkVolume, and set mapper & property
//	vtkVolume *pBaseVolume = vtkVolume::New();
//	pBaseVolume->SetMapper(pBaseVolumeRayCastMapper);
//	pBaseVolume->SetProperty(pBaseVolumeProperty);
//
//	vtkRenderer *pRenderer = vtkRenderer::New();
//	vtkRenderWindow *pRenderWindow = vtkRenderWindow::New();
//	pRenderWindow->AddRenderer(pRenderer);
//	vtkRenderWindowInteractor *pRenderWindowInteractor = 
//		vtkRenderWindowInteractor::New();
//	pRenderWindowInteractor->SetRenderWindow(pRenderWindow);
//
//	// Add the volume to the renderer
//	pRenderer->AddVolume(pBaseVolume);
//
//	// set the background and size
//	pRenderer->SetBackground(0.0, 0.0, 0.0);
//	pRenderWindow->SetParentId(NULL);
//	pRenderWindow->SetSize(1024, 1024);
//	//pRenderWindow->SetAAFrames(4);
//	pRenderer->ResetCamera();
//
//	pRenderWindow->Render();
//
//	// This starts the event loop and as a side effect causes an initial render.
//	pRenderWindowInteractor->Start();
//
//	pBaseVolumeReader->Delete();
//	gaussianSmoothFilter->Delete();
//	pBaseImageCast->Delete();
//	pBaseOpacityTF->Delete();
//	pBaseColorTF->Delete();
//	pBaseVolumeProperty->Delete();
//	pBaseCompositeFunction->Delete();
//	pBaseVolumeRayCastMapper->Delete();
//	pBaseVolume->Delete();
//	pRenderer->Delete();
//	pRenderWindow->Delete();
//	pRenderWindowInteractor->Delete();
//
//	return 0;
//}
